#***************************************************************#
#                                                               #
#                 Replication file (PART 3) for:                #
#                                                               #
#         "The Effect of Anger Appeals on the Support for       #
#                     Secessionist Parties"                     #
#                        Barceló, Joan                          #
#                  Journal of Politics (JOP)                    #
#               Last updated: 10 December 2022                  #
#                                                               #
#****************************************************************

#################
#               #
# Load packages #
#               #
#################

library(rstudioapi)
library(dplyr)

#############
# Load Data #
#############

current_path <- getActiveDocumentContext()$path 
setwd(dirname(current_path))

SurveyExperimentData <- readRDS('SurveyExperimentData.RDS')

#############
# Table 3   #
#############

#Column 1
summary(mc_anger <- lm(mc_anger ~ treatmentgroup, data = SurveyExperimentData))
#Column 2
summary(mc_anger_restricted <- lm(mc_anger ~ treatmentgroup, data = SurveyExperimentData[SurveyExperimentData$identity >= 3,]))
#Column 3
summary(independence_vote_mod <- lm(independence ~ treatmentgroup, data = SurveyExperimentData))
#Column 4
summary(independence_vote_mod_restricted <- lm(independence ~ treatmentgroup, data = SurveyExperimentData[SurveyExperimentData$identity >= 3,]))
#Column 5
summary(parties_vote_mod <- lm(proindy_partiesvote ~ treatmentgroup, data = SurveyExperimentData))
#Column 6
summary(parties_vote_mod_restricted <-  lm(proindy_partiesvote ~ treatmentgroup, data = SurveyExperimentData[SurveyExperimentData$identity >= 3,]))

######################
# Online Appendix N  #
######################

prop.table(table(SurveyExperimentData$gender))*100
prop.table(table(SurveyExperimentData$age))*100
prop.table(table(SurveyExperimentData$education))*100



